/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2015-2019.
 * Description: header for idump parse vma
 * Author: nixiaoming
 * Create: 2015-8-29
 */

#ifndef VMA_IDUMP_H
#define VMA_IDUMP_H
#include <linux/idump_debug.h>

struct vma_dump_region {
	unsigned long start;
	unsigned long size;
};

struct core_name {
	char *corename;
	int used, size;
};

#ifdef CONFIG_RTOS_IDUMP
#define idump_align_up(addr, size)	(((addr) + ((size) - 1)) & (~((size) - 1)))
#define idump_align_down(addr, size)	((addr) & (~((size) - 1)))

struct vma_stack_region {
	unsigned long start;
	unsigned long end;
	unsigned long esp;
	struct task_struct *task;
};

extern bool always_dump_vma(struct vm_area_struct *vma);

extern void idump_vma_metadata_fixup(struct task_struct *task, struct vm_area_struct *vma,
	struct core_vma_metadata *m, struct coredump_params *cprm);
#else
static inline void idump_vma_metadata_fixup(struct task_struct *task, struct vm_area_struct *vma,
	struct core_vma_metadata *m, struct coredump_params *cprm)
{
}

#endif /* CONFIG_RTOS_IDUMP */

#if defined(CONFIG_RTOS_IDUMP_FORCE) || defined(CONFIG_RTOS_IDUMP_TRIGGER)
struct page *get_dump_page_task(struct task_struct *task, unsigned long addr);
#else
static inline struct page *get_dump_page_task(struct task_struct *task,
					      unsigned long addr)
{
	return get_dump_page(addr);
}
#endif

#endif
